/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package optinsa;

/**
 *
 * @author falxa
 */
public class Task {
    
    private int id;
    private Ressource ressource;
    private int duration;
    private int date;
    private int earlydate;
    private int job;
    private boolean done;
    
    public Task(int id, int job, Ressource r, int d)
    {
        this.id = id;
        this.job = job;
        this.ressource = r;
        this.duration = d;
        this.date = 0;
        this.done = false;
    }
    
    public int getID()
    {
        return this.id;
    }
    
    public int getDate()
    {
        return this.date;
    }
    
    public void setDate(int d)
    {
        this.date = d;
    }

    public int getEarlydate() {
        return earlydate;
    }

    public void setEarlydate(int earlydate) {
        this.earlydate = earlydate;
    }
    
    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public int getJob() {
        return job;
    }

    public void setJob(int job) {
        this.job = job;
    }
    
    public Ressource getRessource()
    {
        return this.ressource;
    }
    
    public void doTask(int d)
    {
        this.date = d;
        this.done = true;
        this.ressource.useRessource(this.date + this.duration);
    }
    
    public boolean isDone()
    {
        return this.done;
    }
    
    public String toString()
    {
        String s = "(R"+this.ressource+", "+this.date+")";
        return s;
    }
    
    public void printTask()
    {
        String s = "(R"+this.ressource+", "+this.duration+", ";
        if (this.done)
            s += "DONE -> FROM "+this.date+" to "+(this.date+this.duration)+")";
        else
            s += "NOPE)";
        System.out.print(s); 
    }
}
